let TAITLE		=1;
let NORMAL		=0;
let EXTRA		=0;
let QUIT		=0;
let REI			=1;
let MARI		=0;
let SAKU		=0;
let ico_key		=2;
let ico_key_s		=2;
let ico_key_z		=0;
let key_count		=0;
let key_count_z		=0;
let cursor		=0;
let cursor_s		=0;
let cursor_R		=0;
let cursor_M		=0;
let cursor_S		=0;
let del			=0;
let keyUP		=3;
let keyDOWN		=1;
let keyLEFT		=3;
let keyRIGHT		=1;
let Alpha_t		=255;

function TAITLE_KEY{
		if(TAITLE==1){
if(GetKeyState(VK_DOWN)==KEY_PUSH||GetKeyState(VK_DOWN)==KEY_HOLD||GetKeyState(VK_UP)==KEY_PUSH||GetKeyState(VK_UP)==KEY_HOLD||
GetKeyState(VK_LEFT)==KEY_PUSH||GetKeyState(VK_LEFT)==KEY_HOLD||GetKeyState(VK_RIGHT)==KEY_PUSH||GetKeyState(VK_RIGHT)==KEY_HOLD){key_count++;}

else if(GetKeyState(VK_DOWN)==KEY_PULL||GetKeyState(VK_DOWN)==KEY_FREE||GetKeyState(VK_UP)==KEY_PULL||GetKeyState(VK_UP)==KEY_FREE||
GetKeyState(VK_LEFT)==KEY_PULL||GetKeyState(VK_LEFT)==KEY_FREE||GetKeyState(VK_RIGHT)==KEY_PULL||GetKeyState(VK_RIGHT)==KEY_FREE){key_count=0;}

		if(key_count==1){
			if(GetKeyState(VK_DOWN)==KEY_HOLD||GetKeyState(VK_DOWN)==KEY_PUSH&&ico_key<keyUP){ico_key++;}
			else if(GetKeyState(VK_UP)==KEY_HOLD||GetKeyState(VK_UP)==KEY_PUSH&&ico_key>keyDOWN){ico_key--;}

			if(GetKeyState(VK_RIGHT)==KEY_HOLD||GetKeyState(VK_RIGHT)==KEY_PUSH&&ico_key_s<keyLEFT){ico_key_s++;}
			else if(GetKeyState(VK_LEFT)==KEY_HOLD||GetKeyState(VK_LEFT)==KEY_PUSH&&ico_key_s>keyRIGHT){ico_key_s--;}
		}

	if(GetKeyState(VK_SHOT)==KEY_PUSH||GetKeyState(VK_SHOT)==KEY_HOLD){key_count_z++;}
	else if(GetKeyState(VK_SHOT)==KEY_PULL||GetKeyState(VK_SHOT)==KEY_FREE){key_count_z=0;}
		if(key_count_z==1){ico_key_z=1;}

			if(ico_key==1){
			cursor-=12;
				if(cursor<=-60){
				cursor=-60;
				EXTRA=1;
				}
			}
				else{
				EXTRA=0;
				}
			if(ico_key_z==1&&ico_key==1){
			if(cursor<=-60){
			stage=4;
			GameStart=1;
			}
			}

			if(ico_key==2){
				if(cursor==-60){
				loop(5){
				cursor+=12;
				yield;
				}
				}
				if(cursor==60){
				loop(5){
				cursor-=12;
				yield;
				}
				}
			if(cursor==0){
			cursor=0;
			NORMAL=1;
			}
			}
				else{
				NORMAL=0;
				}
			if(ico_key_z==1&&ico_key==2){
			stage=1;
			GameStart=1;	
			}

			if(ico_key==3){
			cursor+=12;
				if(cursor>=60){
				cursor=60;
				QUIT=1;
				}
			}
				else{
				QUIT=0;
				}
			if(ico_key_z==1&&ico_key==3&&cursor==60){
			Clear();
			}
			}



/***************************LI**********************/

			if(ico_key_s==1){
			cursor_s-=12;
				if(cursor_s<=-120){
				cursor_s=-120;
				MARI=1;
				}
			}
				else{
				MARI=0;
				}

			if(ico_key_s==2){
				if(cursor_s==-120){
				loop(10){
				cursor_s+=12;
				yield;
				}
				}
				if(cursor_s==120){
				loop(10){
				cursor_s-=12;
				yield;
				}
				}
			if(cursor_s==0){
			cursor_s=0;
			REI=1;
			}
			}
				else{
				REI=0;
				}

			if(ico_key_s==3){
			cursor_s+=12;
				if(cursor_s>=120){
				cursor_s=120;
				SAKU=1;
				}
			}
				else{
				SAKU=0;
				}
			


	}

task alp_t{
if(GameStart==1){
	loop(51){
	Alpha_t-=5;
	yield;
	}
}
}

function ICO{
	if(del==1){yield;}
	else{

	//^Cgwi_
	let ty=(cos(mCount/6)*448)%448;
	let tx=(sin(mCount/6)*448)%448;
	SetGraphicRect(tx,ty,384+tx,448+ty);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_t);
	SetTexture(BG_t2);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	//^Cgwi_O
	SetGraphicRect(0,0,384,448);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_t);
	SetTexture(BG_t);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	//EXTRA
	SetGraphicRect(0,0,140,40);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_t);
	SetTexture(taitle);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx-90,cy-60);
	//NORMAL
	SetGraphicRect(0,40,140,80);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_t);
	SetTexture(taitle);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx-90,cy);
	//QUIT
	SetGraphicRect(0,80,140,120);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_t);
	SetTexture(taitle);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx-90,cy+60);
	//J[\
	SetGraphicRect(0,160,140,200);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_t);
	SetTexture(taitle);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx-90,cy+cursor);

	//REI
	SetGraphicRect(0,0,97,285);
	SetGraphicScale(1*(sin(cursor_s+90)^2),1);
	SetAlpha(Alpha_t*(sin(cursor_s+90)^2));
	SetTexture(taitle_ps);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx+90+sin(cursor_s)*90,cy+cos(cursor_s)*20);
	//MARI
	SetGraphicRect(97,0,194,285);
	SetGraphicScale(1*(sin(cursor_s+210)^2),1);
	SetAlpha(Alpha_t*(sin(cursor_s+210)^2));
	SetTexture(taitle_ps);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx+90+sin(cursor_s+120)*90,cy+cos(cursor_s+120)*20);
	//SAKU
	SetGraphicRect(194,0,291,285);
	SetGraphicScale(1*(sin(cursor_s-30)^2),1);
	SetAlpha(Alpha_t*(sin(cursor_s-30)^2));
	SetTexture(taitle_ps);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx+90+sin(cursor_s-120)*90,cy+cos(cursor_s-120)*20);

	}
}